package com.hkts.naturalgas.base.controller;


        import com.alibaba.fastjson.JSON;
        import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
        import com.hkts.naturalgas.base.entity.RoastingtwoPyjone;
        import com.hkts.naturalgas.base.service.IRoastingtwoPyjoneService;
        import com.hkts.naturalgas.utils.CustomPageUtils;
        import com.hkts.naturalgas.utils.Result;
        import com.hkts.naturalgas.utils.ResultUtil;
        import org.slf4j.Logger;
        import org.slf4j.LoggerFactory;
        import org.springframework.beans.factory.annotation.Autowired;
        import org.springframework.web.bind.annotation.*;

        import java.text.ParseException;
        import java.util.List;

/**
 * @author yck
 * @since 2021-06-25
 */
@RestController
@RequestMapping("/instrumentdata/roastingtwoPyjone")
public class RoastingtwoPyjoneController {
    private final Logger logger = LoggerFactory.getLogger(RoastingtwoPyjoneController.class);

    @Autowired
    public IRoastingtwoPyjoneService iRoastingtwoPyjoneService;

    /**
     * 分页查询数据
     *
     * @param page              分页信息
     * @param roastingtwoPyjone 查询条件0
     * @return
     */
    @ResponseBody
    @GetMapping("/getRoastingtwoPyjonePageList")
    public Result<Object> getHontUserList(Page<RoastingtwoPyjone> page, RoastingtwoPyjone roastingtwoPyjone) {
        return ResultUtil.data(CustomPageUtils.getCustomPage(iRoastingtwoPyjoneService.selectPage(page, roastingtwoPyjone)));
    }

    /**
     * 保存和修改公用的
     *
     * @param roastingtwoPyjone 传递的实体
     * @return saveOrUpdate
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/roastingtwoPyjoneSave")
    public Result<Object> roastingtwoPyjoneSave(RoastingtwoPyjone roastingtwoPyjone) {
        iRoastingtwoPyjoneService.saveOrUpdate(roastingtwoPyjone);
        return ResultUtil.success("保存成功");
    }

    /**
     * 根据id获取对象
     *
     * @param id 实体ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/roastingtwoPyjoneGetById")
    public Result<Object> roastingtwoPyjoneGetById(String id) {
        RoastingtwoPyjone byId = iRoastingtwoPyjoneService.getById(id);
        return ResultUtil.data(byId);
    }

    /**
     * 根据id删除对象
     *
     * @param id 实体ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/roastingtwoPyjoneDelete")
    public Result<Object> hontUserDelete(String id) {
        iRoastingtwoPyjoneService.removeById(id);
        return ResultUtil.success("删除成功");
    }

    /**
     * 批量删除对象
     *
     * @param item 实体集合ID
     * @return 0 失败  1 成功
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/roastingtwoPyjoneBatchDelete")
    public Result<Object> deleteBatchIds(String item) {
        List<String> ids = (List<String>) JSON.parse(item);
        iRoastingtwoPyjoneService.removeByIds(ids);
        return ResultUtil.success("删除成功");
    }
    /** 功能描述:
     *  生成排烟架数据
     * @return:
     * @Author: 杨春科
     * @Date: 2021-06-26 10:52
     * @Description //TODO
     */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/addHostoryData")
    public Result<String> addHostoryData(String startDate,String endDate) throws ParseException {
        iRoastingtwoPyjoneService.addHostoryData(startDate,endDate);
        return ResultUtil.data("处理成功");
    }
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/handlerPresserData")
    public Result<String> handlerPresserData(String endDate) throws ParseException {
        iRoastingtwoPyjoneService.handlerPresserData(endDate);
        return ResultUtil.data("处理成功");
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/handlerCurveData")
    public Result<String> handlerCurveData(String startDate,String endDate,Float mbt,String order) throws ParseException {
        iRoastingtwoPyjoneService.handlerCurveData(startDate,endDate,mbt,order);
        return ResultUtil.data("处理成功");
    }
    /** 功能描述:
    *处理在线数据bug
    * @return:
    * @Author: 杨春科
    * @Date: 2021-07-02 15:32
    * @Description //TODO
    */
    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/handlerBugData")
    public Result<String> handlerBugData(){
        iRoastingtwoPyjoneService.handlerBugData();
        return ResultUtil.data("处理成功");
    }


}
